package io.renren.sf.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.common.utils.R;
import io.renren.sf.entity.CbPcsystemEditionEntity;
import io.renren.sf.entity.CbStiffBookEntity;
import io.renren.sf.entity.CbStiffSystemEntity;
import io.renren.sf.service.CbPcsystemEditionService;
import io.renren.sf.service.CbStiffBookService;
import io.renren.sf.service.CbStiffSystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * @author cyl_txw
 * @email cyl_txw@gmail.com
 * @date 2021-03-31 13:04:11
 */
@RestController
@RequestMapping("sf/cbpcsystemedition")
public class CbPcsystemEditionController {
    @Autowired
    private CbPcsystemEditionService cbPcsystemEditionService;

    /**
     * 硬笔系统分页
     */
    @GetMapping("/list")
    public R pcsystemEditionPage(@RequestParam Map<String, Object> params) {
        long page = Long.parseLong((String) params.get("page"));
        long limit = Long.parseLong((String) params.get("limit"));
        Page<CbPcsystemEditionEntity> pcsystemEditionPage = new Page<>(page, limit);
        cbPcsystemEditionService.page(pcsystemEditionPage);
        return R.ok().put("pcsystemEditionPage", pcsystemEditionPage);
    }
    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
        CbPcsystemEditionEntity pcsystemEditionEntity = cbPcsystemEditionService.getById(id);

        return R.ok().put("pcsystemEdition", pcsystemEditionEntity);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody CbPcsystemEditionEntity pcsystemEditionEntity){
        pcsystemEditionEntity.setCreatetime(new Date());
        cbPcsystemEditionService.save(pcsystemEditionEntity);
        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody CbPcsystemEditionEntity pcsystemEditionEntity){
        cbPcsystemEditionService.updateById(pcsystemEditionEntity);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        cbPcsystemEditionService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
